package com.moniteach.server.db.bo;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import org.json.JSONObject;

import com.moniteach.utils.Resource;

@PersistenceCapable
public class UserInfo {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;

	@Persistent
	private String email;

	@Persistent
	private String pass;

	@Persistent
	private String fName;

	@Persistent
	private String lName;

	@Persistent
	private String sName;

	@Persistent
	private String phone;

	@Persistent
	private String role;

	@Persistent
	private String pincode;

	@Persistent
	private Boolean active;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPass() {
		return pass;
	}

	public void setPass(String pass) {
		this.pass = pass;
	}

	public String getfName() {
		return fName;
	}

	public void setfName(String fName) {
		this.fName = fName;
	}

	public String getlName() {
		return lName;
	}

	public void setlName(String lName) {
		this.lName = lName;
	}

	public String getsName() {
		return sName;
	}

	public void setsName(String sName) {
		this.sName = sName;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getRole() {
		return role;
	}

	public void setRole(String role) {
		this.role = role;
	}

	public String getPincode() {
		return pincode;
	}

	public void setPincode(String pincode) {
		this.pincode = pincode;
	}

	public Boolean getActive() {
		return active;
	}

	public void setActive(Boolean active) {
		this.active = active;
	}

	public UserInfo(Long id, String email, String pass, String fName,
			String lName, String sName, String phone, String role,
			String pincode, Boolean active) {
		super();
		this.id = id;
		this.email = email;
		this.pass = pass;
		this.fName = fName;
		this.lName = lName;
		this.sName = sName;
		this.phone = phone;
		this.role = role;
		this.pincode = pincode;
		this.active = active;
	}

	public UserInfo(String email, String pass, String fName, String lName,
			String sName, String phone, String role, String pincode,
			Boolean active) {
		super();
		this.email = email;
		this.pass = pass;
		this.fName = fName;
		this.lName = lName;
		this.sName = sName;
		this.phone = phone;
		this.role = role;
		this.pincode = pincode;
		this.active = active;
	}

	public JSONObject toJSONObject() {
		JSONObject jo = new JSONObject();
		jo.put(Resource.Const.id, (id != null ? id : -1));
		jo.put(Resource.Const.email, (email != null ? email : ""));
		jo.put(Resource.Const.pass, (pass != null ? pass : ""));
		jo.put(Resource.Const.fName, (fName != null ? fName : ""));
		jo.put(Resource.Const.lName, (lName != null ? lName : ""));
		jo.put(Resource.Const.sName, (sName != null ? sName : ""));
		jo.put(Resource.Const.phone, (phone != null ? phone : ""));
		jo.put(Resource.Const.role, role);
		jo.put(Resource.Const.pincode, (pincode != null ? pincode : ""));
		jo.put(Resource.Const.active, active);
		return jo;
	}
}
